package com.mini.es.service;

import com.mini.util.ExpireTime;
import com.mini.util.RedisCacheUtils;
import com.mini.util.StringUtil;
import org.springframework.stereotype.Service;

@Service
public class UserFieldsServiceImpl {

    private String userFieldsKey = "UserFieldsKey";


    public String getUserQueryFields(Long userId){

        String key = userFieldsKey+"_"+userId;

        String fields = RedisCacheUtils.getStr(key);
        if(StringUtil.notEmpty(fields)){
            return fields;
        }
        RedisCacheUtils.set(key,"ALL", ExpireTime.ONE_MON);

        return "ALL";
    }

    public void SetUserQueryFields(Long userId,String fields){
        String key = userFieldsKey+"_"+userId;
        RedisCacheUtils.set(key,fields,ExpireTime.ONE_MON);
    }
}
